package com.nb.customprocessbar;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private CustomProcessBar mCustomProcessBar;
    private ValueAnimator valueAnimator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mCustomProcessBar = findViewById(R.id.process_bar);
        valueAnimator = ValueAnimator.ofFloat(0, 1);
        valueAnimator.setDuration(3000);
        valueAnimator.addUpdateListener(animation -> {
            float process = (float) animation.getAnimatedValue();
            mCustomProcessBar.setProcess(process);
        });


    }

    public void start(View view) {
        valueAnimator.start();
    }
}